import userApi from '@/api/modules/user.js'
import { getToken, removeToken } from '@/utils/auth'
const state = {
  id: 0,
  userName: '',
  nickName: '',
  mobile: '',
  avatar: '',
  roles: []
}

const mutations = {
  SET_ID: (state, id) => {
    state.id = id
  },
  SET_NICKNAME: (state, nickName) => {
    state.nickName = nickName
  },
  SET_USERNAME: (state, userName) => {
    state.userName = userName
  },
  SET_MOBILE: (state, mobile) => {
    state.mobile = mobile
  },
  SET_AVATAR: (state, avatar) => {
    state.avatar = avatar
  },
  SET_ROLES: (state, roles) => {
    state.roles = roles
  }
}

const actions = {
	// 获取自己的信息
	getOwnInfo({ commit, state }) {		
		return new Promise((resolve, reject) => {
			userApi.getOwnInfo().then(response => {
				console.log(response)
			}).catch(err=>{
				
			})
		})          
	} 
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
